home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d6 / glazer.arc / RULEOF78.BAS < prev    next >
BASIC Source File  |  1988-10-07  |  2KB  |  53 lines

  1. 100 'Rule of 78s ("RULEOF78S")
  2. 110 CLS
  3. 120 COLOR 0,15 :  PRINT "Rule of 78s" :  COLOR 15,0
  4. 130 DEFDBL A-Z
  5. 140 DEFINT M-N
  6. 150 MONEYFMT$ = "$$##,###,###.##"
  7. 160 '     Define rounding function
  8. 170 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
  9. 180 '     Let user enter data
  10. 190 PRINT
  11. 200 PRINT "Do not enter dollar signs or commas"
  12. 210 PRINT
  13. 220 INPUT "Amount of loan: ", PNCPL
  14. 230 INPUT "Term (in months): ", NMONTHS
  15. 240 INPUT "Annual interest rate (in percent): ", AR
  16. 250 PRINT "Enter date of first payment"
  17. 260 INPUT "  Month (1-12): ", MONTH
  18. 270 IF MONTH < 1 OR MONTH > 12  THEN PRINT "No such month" : GOTO 260
  19. 280 INPUT "  Year (1900-2100): ", YEAR
  20. 290 IF YEAR < 1900 OR YEAR > 2100  THEN PRINT "Year out of range" : GOTO 280
  21. 300 '     Find monthly payment
  22. 310 PR = AR / 1200
  23. 320 IF PR <> 0 THEN PMT = PNCPL * PR / ( 1 - (1 + PR) ^ -NMONTHS)                              ELSE PMT = PNCPL / NMONTHS
  24. 330 PMT = FNR (PMT)
  25. 340 PRINT : PRINT "Monthly payment:" ;  USING MONEYFMT$ ; PMT
  26. 350 TFC = PMT * NMONTHS-PNCPL  'Total finance charges
  27. 360 PRINT
  28. 370 '     Amortization
  29. 380 PRINT "Press Enter to see next month's results"
  30. 390 TOTALINTEREST = 0
  31. 400 MONTHNUM = YEAR * 12 + MONTH   'Number of months since date 0
  32. 410 FOR M = 1 TO NMONTHS
  33. 420   'Wait for user to press Enter
  34. 430   INPUT "", K$
  35. 440   'Finance charge for the month
  36. 450   INTERESTDUE = TFC * 2 * (NMONTHS - M + 1) / (NMONTHS * (NMONTHS + 1) )
  37. 460   TOTALINTEREST = TOTALINTEREST + INTERESTDUE
  38. 470   CURRENTPNCPL = PNCPL + TOTALINTEREST - M * PMT    'New principal
  39. 480   'Determine the date
  40. 490   YEAR = (MONTHNUM - 1) \ 12
  41. 500   MONTH = MONTHNUM - YEAR * 12
  42. 510   MONTHNUM = MONTHNUM + 1
  43. 520   '     Print the month's results
  44. 530   PRINT: PRINT
  45. 540   PRINT "Payment number: " ;  M
  46. 550   PRINT "Date: " ;  MONTH ;  "/" ;  YEAR
  47. 560   PRINT
  48. 570   PRINT "Principal: "; TAB(22); USING MONEYFMT$; CURRENTPNCPL
  49. 580   PRINT "Interest due: " ; TAB(22); USING MONEYFMT$; INTERESTDUE
  50. 590   PRINT "Cumulative interest: " ; TAB(22) ; USING MONEYFMT$; TOTALINTEREST
  51. 600 NEXT M
  52. 610 END
  53.